﻿namespace UFIDA.U9.Cust.SH.SHFastShipBP
{
	using System;
	using System.Collections.Generic;
	using System.Text; 
	using UFSoft.UBF.AopFrame;	
	using UFSoft.UBF.Util.Context;
    using UFSoft.UBF.Util.DataAccess;

	/// <summary>
	/// GetDocNo partial 
	/// </summary>	
	public partial class GetDocNo 
	{	
		internal BaseStrategy Select()
		{
			return new GetDocNoImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class GetDocNoImpementStrategy : BaseStrategy
	{
		public GetDocNoImpementStrategy() { }

		public override object Do(object obj)
		{						
			GetDocNo bpObj = (GetDocNo)obj;
			
			//get business operation context is as follows
			//IContext context = ContextManager.Context	
			
			//auto generating code end,underside is user custom code
			//and if you Implement replace this Exception Code...
			//throw new NotImplementedException();
            if (String.IsNullOrEmpty(bpObj.Prefix))
                throw new Exception("单号生成错误，前缀为空！");
            string docno="";
            long num = 0;

            DataParamList lst=new DataParamList();
            lst.Add(DataParamFactory.CreateInput("StrKey", bpObj.Prefix, System.Data.DbType.String));
            lst.Add(DataParamFactory.CreateInputOutput("DocNo", num, System.Data.DbType.Int64));
            DataAccessor.RunSP(DataAccessor.GetConn(), "P_Cust_WS_GetDocNo", lst);

            docno = bpObj.Prefix + lst[1].Value.ToString().PadLeft(5, '0');
            return docno;
		}		
	}

	#endregion
	
	
}